package com.huey.utils.api;

import com.huey.utils.annotation.aop.CustomCache;
import com.huey.utils.annotation.filed.User;
import com.huey.utils.annotation.method.CheckPermission;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * @author xubo
 * @date 2022/7/12 14:52
 */
@RestController
@RequestMapping("Annotation")
@Validated
public class AnnotationController {


    @PostMapping(value = "user")
    public String testFiled(@Valid @RequestBody User user) {
        System.out.println(user);
        return "do something you like ------";
    }

    @CheckPermission(userCode = "admin" ,userName = "admin")
    @PostMapping(value = "admin")
    public String testMethod(@Valid @RequestBody User user) {
        System.out.println(user);
        return "do something you like ------";
    }

    @GetMapping("cache")
    @CustomCache(key = "testKey")
    public Object testCustomCache() {
        return "don't hit cache -------------";
    }
}
